using EastenCommunication.BasicFramework;
using EastenCommunication.Enthernet;
using System;
using System.Security.Cryptography;
using System.Text;
using System.Threading;

namespace EastenCommunication
{
	/// <summary>
	/// 系统的基本授权类
	/// </summary>
	public class Authorization
	{
		private static readonly string Declaration;

		private static DateTime niahdiahduasdbubfas;

		internal static long naihsdadaasdasdiwasdaid;

		internal static long moashdawidaisaosdas;

		internal static double nuasgdawydbishcgas;

		internal static int nuasgdaaydbishdgas;

		internal static int nuasgdawydbishdgas;

		internal static double nuasgdawydaishdgas;

		internal static int nasidhadguawdbasd;

		internal static int niasdhasdguawdwdad;

		internal static int hidahwdauushduasdhu;

		internal static long iahsduiwikaskfhishfdi;

		internal static int zxnkasdhiashifshfsofh;

		static Authorization()
		{
			Declaration = "禁止对本组件进行反编译，篡改源代码，如果用于商业用途，将追究法律责任，如需注册码，请联系作者，QQ号：200962190，邮箱：hsl200909@163.com，欢迎企业合作。";
			niahdiahduasdbubfas = DateTime.Now;
			naihsdadaasdasdiwasdaid = 0L;
			moashdawidaisaosdas = 0L;
			nuasgdawydbishcgas = 8.0;
			nuasgdaaydbishdgas = 0;
			nuasgdawydbishdgas = 8;
			nuasgdawydaishdgas = 8.0;
			nasidhadguawdbasd = 1000;
			niasdhasdguawdwdad = 12345;
			hidahwdauushduasdhu = 23456;
			iahsduiwikaskfhishfdi = 0L;
			zxnkasdhiashifshfsofh = 0;
			niahdiahduasdbubfas = iashdagsdawbdawda();
			if (naihsdadaasdasdiwasdaid != 0)
			{
				naihsdadaasdasdiwasdaid = 0L;
			}
			if (nuasgdawydaishdgas != 8.0)
			{
				nuasgdawydaishdgas = 8.0;
			}
			if (nuasgdaaydbishdgas != 0)
			{
				nuasgdaaydbishdgas = 0;
			}
		}

		private static void asidhiahfaoaksdnasoif(object obj)
		{
			for (int i = 0; i < 3600; i++)
			{
				Thread.Sleep(1000);
				if (naihsdadaasdasdiwasdaid == niasdhasdguawdwdad && nuasgdaaydbishdgas > 0)
				{
					return;
				}
			}
			NetSimplifyClient netSimplifyClient = new NetSimplifyClient("118.24.36.220", 18467);
			netSimplifyClient.ReadCustomerFromServer(500, SoftBasic.FrameworkVersion.ToString());
		}

		internal static bool nzugaydgwadawdibbas()
		{
			moashdawidaisaosdas++;
			if (naihsdadaasdasdiwasdaid == niasdhasdguawdwdad && nuasgdaaydbishdgas > 0)
			{
				return nuasduagsdwydbasudasd();
			}
			if (zxnkasdhiashifshfsofh > 10)
			{
				return asdhuasdgawydaduasdgu();
			}
			if ((iashdagsdawbdawda() - niahdiahduasdbubfas).TotalHours < nuasgdawydaishdgas)
			{
				return nuasduagsdwydbasudasd();
			}
			return asdhuasdgawydaduasdgu();
		}

		internal static bool nuasduagsdwydbasudasd()
		{
			return true;
		}

		internal static bool asdhuasdgawydaduasdgu()
		{
			return false;
		}

		internal static bool ashdadgawdaihdadsidas()
		{
			return niasdhasdguawdwdad == 12345;
		}

		internal static DateTime iashdagsdawbdawda()
		{
			return DateTime.Now;
		}

		internal static DateTime iashdagsaawbdawda()
		{
			return DateTime.Now.AddDays(1.0);
		}

		internal static DateTime iashdagsaawadawda()
		{
			return DateTime.Now.AddDays(2.0);
		}

		internal static void oasjodaiwfsodopsdjpasjpf()
		{
			if (Interlocked.Increment(ref iahsduiwikaskfhishfdi) >= 100)
			{
				zxnkasdhiashifshfsofh = 100;
			}
		}

		internal static string nasduabwduadawdb(string miawdiawduasdhasd)
		{
			StringBuilder stringBuilder = new StringBuilder();
			MD5 mD = MD5.Create();
			byte[] array = mD.ComputeHash(Encoding.Unicode.GetBytes(miawdiawduasdhasd));
			mD.Clear();
			for (int i = 0; i < array.Length; i++)
			{
				stringBuilder.Append((255 - array[i]).ToString("X2"));
			}
			return stringBuilder.ToString();
		}

		/// <summary>
		/// 设置本组件系统的授权信息，如果激活失败，只能使用8小时，8小时后所有的网络通信不会成功<br />
		/// Set the authorization information of this component system. If the activation fails, it can only be used for 8 hours. All network communication will not succeed after 8 hours
		/// </summary>
		/// <param name="code">授权码</param>
		public static bool SetAuthorizationCode(string code)
		{
			if (nasduabwduadawdb(code) == "D52DDF46718BA63772D40DD3A9452D41")
			{
				nuasgdaaydbishdgas = 1;
				nuasgdawydbishcgas = 286512937.0;
				nuasgdawydaishdgas = 175200.0;
				return nuasduagsdwydbasudasd();
			}
			if (nasduabwduadawdb(code) == "B7D40F4D8B229E02AC463A096BCD5707")
			{
				nuasgdaaydbishdgas = 1;
				iahsduiwikaskfhishfdi = long.MinValue;
				nuasgdawydbishcgas = 286512937.0;
				nuasgdawydaishdgas = 2160.0;
				return nuasduagsdwydbasudasd();
			}
			if (nasduabwduadawdb(code) == "2765FFFDDE2A8465A9522442F5A15593")
			{
				nuasgdaaydbishdgas = 10000;
				nuasgdawydbishcgas = nuasgdawydbishdgas;
				naihsdadaasdasdiwasdaid = niasdhasdguawdwdad;
				return nuasduagsdwydbasudasd();
			}
			return asdhuasdgawydaduasdgu();
		}
	}
}
